package com.portlet.donggoi.controller;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.util.bridges.mvc.MVCPortlet;


import com.portlet.donggoi.model.quytrinhDG;
import com.portlet.donggoi.service.quytrinhDGLocalServiceUtil;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;

public class quanLyQTDG  extends MVCPortlet{
	public void addQT(ActionRequest actionRequest, ActionResponse actionResponse)
			throws SystemException {
		String maQT = actionRequest.getParameter("maQT");
		String tenQT = actionRequest.getParameter("tenQT");

		quytrinhDG qt =quytrinhDGLocalServiceUtil.createquytrinhDG(maQT);
		qt.setTenQuyTrinh(tenQT);
		quytrinhDGLocalServiceUtil.addquytrinhDG(qt);

		System.out.println("Them thanh cong bo phan");
		actionResponse.setRenderParameter("JspPage", "/view.jsp");
	}
	public void editQTDG(ActionRequest actionRequest,
			ActionResponse actionResponse) throws PortalException,
			SystemException {
		String maQT = actionRequest.getParameter("maQT");
		quytrinhDG qt = quytrinhDGLocalServiceUtil.getquytrinhDG(maQT);

		System.out.println(qt.toString());
		actionRequest.setAttribute("edit", qt);
		actionResponse.setRenderParameter("jspPage", "/editQT.jsp");
	}
	public void updatenameQTURL(ActionRequest actionRequest,
			ActionResponse actionResponse) throws PortalException,
			SystemException {
		String maQT = actionRequest.getParameter("maQT");
		String tenQT = actionRequest.getParameter("tenQT");

		quytrinhDG qt = quytrinhDGLocalServiceUtil.createquytrinhDG(maQT);
		qt.setTenQuyTrinh(tenQT);
		quytrinhDGLocalServiceUtil.updatequytrinhDG(qt);

		System.out.println("Cập nhật thành công");
		actionResponse.setRenderParameter("jspPage", "/view.jsp");
	}
	public void deleteQT(ActionRequest actionRequest,
			ActionResponse actionRespons) throws PortalException, SystemException{
		String maQT=actionRequest.getParameter("edit");
		quytrinhDG qt=quytrinhDGLocalServiceUtil.getquytrinhDG(maQT);
		quytrinhDGLocalServiceUtil.deletequytrinhDG(qt);
		System.out.println("Xoa thanh cong");
		actionRespons.setRenderParameter("jspPage", "/view.jsp");
	}
}
